package ru.ifmo.croak.impl.stress.post.team3;

import ru.ifmo.croak.api.PostService;

/**
 * @author Artem Bochkarev
 * 
 */
public class SimpleSender implements Runnable {

	private final int delay;
	private final PostService postService;

	public SimpleSender(int delay, PostService postService) {
		this.delay = delay;
		this.postService = postService;
	}

	@Override
	public void run() {
		try {
			while (true) {
				postService.postMessage(RandomMessage.nextMessage());
				Thread.sleep(delay);
			}
		} catch (Exception e) {
		}
	}
}
